import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    user: null,
    cart: []
  },
  mutations: {
    setUser(state, user) {
      state.user = user
    },
    addToCart(state, product) {
      state.cart.push(product)
    }
  },
  actions: {
    login({ commit }, user) {
      commit('setUser', user)
    },
    addProductToCart({ commit }, product) {
      commit('addToCart', product)
    }
  },
  modules: {}
})